<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%
    String path = request.getContextPath();
	if (path.equals("/")) {path = "";}
	pageContext.setAttribute("path", path);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>后台管理---修改密码</title>
        <link rel="shortcut icon" type="image/x-icon" href="${path}/favicon.ico" >
       	<link rel="stylesheet" type="text/css" href="${path}/css/manage_center.css"/>  
       	<script type="text/javascript" src="${path}/js/jquery/jquery-1.5.1.js"></script>
       	<script type="text/javascript" src="${path}/js/jquery/jquery.corner.js"></script>  
		<script type="text/javascript" src="${path}/js/jquery/jquery-ui-1.8.11.custom.js"></script>
        <script type="text/javascript" src="${path}/js/common.js"></script>
        
        
        <script type="text/javascript">			
		
       //query同步get请求	
		$.ajaxSetup({   
			async : false  
		});
        
		//校验老密码
		function checkOldPassword() {
			var e_hint = $("#oldPassword_hint");
			var oldPassword = fm.oldPassword.value;
			if(oldPassword.length > 32 || trim(oldPassword) == "" ){				
				e_hint.html("<font color=red>旧密码不能为空！</font>");
				return false;
			} else {
				var state = false;
				var url = "adminmgr/user_checkOldPass?oldPassword="+oldPassword;
				$.get(url,null,function(data){
			   		if(data=='fault'){
						e_hint.html("<font color=red>旧密码不正确!</font>");
			   		}else if(data == 'success'){					
						e_hint.html("");
						state = true;	
					}
				}, "text");
				return state;
			}
		}
		
		//校验新密码
		function checkNewPassword() {
			var e_hint = $("#newPassword_hint");
			var newPassword = fm.newPassword.value;
			if(trim(newPassword) == ""){
				e_hint.html("<font color=red>新密码不能为空!</font>");	
				return false;
			}else if(newPassword.length < 4 || newPassword.length > 12){
				e_hint.html("<font color=red>新密码长度4-12位之间!</font>");	
				return false;
			}else {
				e_hint.html("");
				return true;
			}
		}
		
		//校验确认的新密码
		function checkAgainPassword() {
			var e_hint = $("#againPassword_hint");
			var againPassword = fm.againPassword.value;
			var newPassword = fm.newPassword.value;
			if(againPassword.length > 32 || trim(againPassword) == "" ){				
				e_hint.html("<font color=red>再次输入不能为空！</font>");
				return false;
			} else {
				if(newPassword.length > 32 || trim(newPassword) == "" ){			
					var newPassword_hint = $("#newPassword_hint");	
					newPassword_hint.html("<font color=red>新密码不能为空！</font>");
					e_hint.html("");
					return false;
				}else{
					if(againPassword == newPassword){
						e_hint.html("");
						return true;
					}else{
						e_hint.html("<font color=red>新密码两次输入不一致！</font>");
						return false;
					}
				}
			}
		}
		
		//submit统一验证数据合法性
		function getFlag(){		
			var state=checkOldPassword() && checkNewPassword() && checkAgainPassword();				
			return state;			
		}
		</script>
        
    </head>

    <body >
    	 <div id="right0">
         	<table class="all_table">
         		<tr>
         			<td align="center">         
				    	<div id="allContext" class="png_bg" >
							<form action="adminmgr/user_modifyUserPass" method="post" name="fm" onsubmit="return getFlag()"> 
					            <table id="tableContext" align="center"> 
					                <tbody> 
					                	<tr height="35"> 
					                        <td colspan="3"></td> 
					                    </tr> 
					                	<tr align="center"> 
					                        <td class="titleAll" colspan="3">修改密码</td> 
					                    </tr> 
					                    <tr height="40"> 
					                        <td class="data_left">旧密码: </td> 
					                        <td class="data_mid"> 
					                        	<input type="password" class="normaltxt" name="oldPassword" value="" style="line-height: 20px;" maxlength="40" onblur="checkOldPassword()"> 
					                        </td> 
					                        <td class="data_right"><span id="oldPassword_hint"></span></td> 
					                    </tr> 
					                    
					                    <tr height="40"> 
					                        <td class="data_left">新密码: </td> 
					                        <td class="data_mid"> 
					                        	<input type="password" class="normaltxt" name="newPassword" value="" style="line-height: 20px;" maxlength="40" onblur="checkNewPassword()"> 
					                        </td> 
					                        <td class="data_right"><span id="newPassword_hint"></span></td> 
					                    </tr> 
					                    
					                    <tr height="40"> 
					                        <td class="data_left">再次输入新密码: </td> 
					                        <td class="data_mid"> 
					                        	<input type="password" class="normaltxt" name="againPassword" value="" style="line-height: 20px;" maxlength="40" onblur="checkAgainPassword()"> 
					                        </td> 
					                        <td class="data_right"><span id="againPassword_hint"></span></td> 
					                    </tr> 
					                                      
					                    <tr> 
					                        <td class="foot" colspan="3" align="center"> 
						                        <input type="submit" id="sameSubmit" class="button_fy_deep" value="提交"> &nbsp;&nbsp;&nbsp;
						            			<input type="reset" class="button_fy_deep" value="重置"> 
						            		</td> 
					                    </tr> 
					                </tbody> 
					            </table> 
				            </form>
				        </div>
        			</td>
   				</tr>
   			</table>
   		</div>
   		<script type="text/javascript">
       //变成圆角 
	   becomeCorner('all_table');
	   </script>
    </body>
</html>
